package com.alibaba.sample.kantiezi.web.admin.module.screen;

import com.alibaba.biz.command.Command;
import com.alibaba.biz.command.CommandSupport;
import com.alibaba.biz.command.dispatcher.CommandDispatcher;
import com.alibaba.biz.command.result.Result;

import com.alibaba.service.template.TemplateContext;

import com.alibaba.turbine.module.screen.TemplateScreen;
import com.alibaba.turbine.service.rundata.RunData;

import com.alibaba.webx.WebxException;

import java.util.List;

public abstract class CategoryList extends TemplateScreen {
    protected abstract CommandDispatcher getCommandDispatcher();

    protected void execute(RunData rundata, TemplateContext context)
            throws WebxException {
        Command command = new CommandSupport("categoryList");
        Result  result  = getCommandDispatcher().execute(command);

        if (result.isSuccess()) {
            List cats = (List) result.getDefaultModel();

            context.put("cats", cats);
        }
    }
}
